package com.springboot.mq.config;

import com.springboot.mq.pojo.Message;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.jms.annotation.JmsListener;
import org.springframework.jms.core.JmsMessagingTemplate;
import org.springframework.stereotype.Component;

import javax.jms.Queue;

/**
 * @author wangning
 * @create 2021-05-11 10:01
 */
@Component
public class JmsComponent {
	@Autowired
	JmsMessagingTemplate messagingTemplate;
	@Autowired
	Queue queue;

	public void send(Message msg) {
		messagingTemplate.convertAndSend(this.queue, msg);
	}

	@JmsListener(destination = "amq")
	public void receive(Message msg) {
		System.out.println("receive:" + msg);
	}

}

